<?php

/**
 * Auth: day
 * Date: 2018/08/09 14:00
 * Description: partner 表相关操作
 */

namespace App\Services\ThirdAPI;

use App\Models\Partner;
use App\Models\HallPartner;

class PartnerService
{

    //查找游戏的种类
    public static function getGame3thList()
    {
        return Partner::select(['id', 'name'])->get()->toArray();
    }

    /**
     * 通过 厅ID 和 第三方游戏名获取第三方游戏配置
     */
    public static function getGameConfigByName($tid, $gamename)
    {
        $hp = HallPartner::where(['hall_id' => $tid, 'partner_name' => strtoupper($gamename)])->first();
        if ($hp) {
            return json_decode($hp->game_config, true);
        }
        return [];
    }

    /**
     * 通过 厅ID 和 第三方游戏名获取第三方游戏配置
     */
    public static function getDefaultGameConfig($gamename)
    {
        $p = Partner::where(['partner_name' => strtoupper($gamename)])->first();
        if ($p) {
            return  json_decode($p->default_config, true);
        }
        return [];
    }
}
